#coding=utf-8
import unittest
import os
import sys
import time
import  random
from xlwt import *
import xlrd
from xlutils.copy import copy
import urllib2
from bs4 import BeautifulSoup



class result_Operate():
    def get_result(self,caselist,result_file):
        # htmlfile = open('D:/Cruise/pythonSrc/reprot/egova-test-2016-10-26-39.1815900622.html','r')
        htmlfile = open(result_file,'r')
        htmlpage = htmlfile.read()
        soup = BeautifulSoup(htmlpage, "html.parser")
        print soup.a
        # print soup.find_all(class_='popup_link')
        result_list =[]
        pass_flag = '        p'
        fail_flag = '        f'
        fail_flag = '        e'
        caseid =0
        for a in soup.select('a'):
            if pass_flag in a.get_text() or fail_flag in a.get_text():
                result = a.get_text()[9:]
                result_full = [caselist[caseid][1],result]
                # print caselist[caseid]
                caseid = caseid+1
                result_list.append(result_full)
        print result_list
        return  result_list

    def test(self):
        return 0

if __name__ == '__main__':
    test = result_Operate()
    url = 'D:/Cruise/pythonSrc/reprot/egova-test-2017-04-12-362.277292137.html'
    caselist = ['test1','test2']
    test.get_result(caselist)
    unittest.main()
